From: Dale Wijnand Date: Mon, 16 Apr 2018 22:17:57 +0000 (+0200) Subject: Increase scope nesting to borrow X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~52^2~6 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=ad60c60d04b7d6241a1391847558bb98beb9fe70;p=cargo.git Increase scope nesting to borrow --- diff --git a/src/cargo/util/toml/targets.rs b/src/cargo/util/toml/targets.rs index 896278c49..168245ec1 100644 --- a/src/cargo/util/toml/targets.rs +++ b/src/cargo/util/toml/targets.rs @@ -317,31 +317,37 @@ fn clean_benches( warnings: &mut Vec, errors: &mut Vec, ) -> CargoResult> { - let mut legacy_bench_path = |bench: &TomlTarget| { - let legacy_path = package_root.join("src").join("bench.rs"); - if !(bench.name() == "bench" && legacy_path.exists()) { - return None; - } - warnings.push(format!( - "path `{}` was erroneously implicitly accepted for benchmark `{}`,\n\ - please set bench.path in Cargo.toml", - legacy_path.display(), - bench.name() - )); - Some(legacy_path) - }; + let mut legacy_warnings = vec![]; + + let targets = { + let mut legacy_bench_path = |bench: &TomlTarget| { + let legacy_path = package_root.join("src").join("bench.rs"); + if !(bench.name() == "bench" && legacy_path.exists()) { + return None; + } + legacy_warnings.push(format!( + "path `{}` was erroneously implicitly accepted for benchmark `{}`,\n\ + please set bench.path in Cargo.toml", + legacy_path.display(), + bench.name() + )); + Some(legacy_path) + }; - let inferred = infer_from_directory(&package_root.join("benches")); + let inferred = infer_from_directory(&package_root.join("benches")); + + clean_targets_with_legacy_path( + "benchmark", + "bench", + toml_benches, + &inferred, + package_root, + errors, + &mut legacy_bench_path, + )? + }; - let targets = clean_targets_with_legacy_path( - "benchmark", - "bench", - toml_benches, - &inferred, - package_root, - errors, - &mut legacy_bench_path, - )?; + warnings.append(&mut legacy_warnings); let mut result = Vec::new(); for (path, toml) in targets {